/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package bpmlab.kivulifx.util;

import bpmlab.kivulifx.Main;
import bpmlab.kivulifx.controller.IndexController;
import bpmlab.kivulifx.controller.NewProjectController;
import bpmlab.kivulifx.controller.WorkspaceController;
import java.io.IOException;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.layout.BorderPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/**
 *
 * @author bpmlab
 */
public class DialogsCustom {
    
    public static boolean newProject() {
        try {
            FXMLLoader loader = new FXMLLoader(IndexController.class.getResource("/fxml/NewProject.fxml"));
            BorderPane root = (BorderPane) loader.load();
            
            Dialog dialog = new Dialog();
            dialog.setHeaderText("New Project");
            dialog.initModality(Modality.APPLICATION_MODAL);
            dialog.getDialogPane().setContent(root);
            
            NewProjectController controller = loader.getController();
            controller.setDialog((Stage) dialog.getDialogPane().getScene().getWindow());
            
            dialog.showAndWait();
            
            return controller.isOkClicked();
        } catch (IOException ex) {
            return false;
        }
    }
    
    public static void workspace() {
        try {
            FXMLLoader loader = new FXMLLoader(IndexController.class.getResource("/fxml/Workspace.fxml"));
            Node root = (Node) loader.load();
            
            Dialog dialog = new Dialog();
            dialog.setHeaderText("Chooser Workspace");
            dialog.initModality(Modality.APPLICATION_MODAL);
            dialog.getDialogPane().setContent(root);
            dialog.initStyle(StageStyle.UNDECORATED);
            
            WorkspaceController controller = loader.getController();
            controller.setDialog((Stage) dialog.getDialogPane().getScene().getWindow());
            
            dialog.showAndWait();
        } catch (IOException ex) {
        }
    }
}
